package com.ihg.hiex.admin.service.account.impl;

import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.annotation.Dao;
import com.ihg.hiex.admin.dao.account.SupervisorDao;
import com.ihg.hiex.admin.service.DataServiceImpl;
import com.ihg.hiex.admin.service.account.SupervisorService;
import com.ihg.hiex.entity.user.Account;
import com.ihg.hiex.entity.user.Supervisor;

/**
 *
 * @author Ark
 *
 */
@Service("supervisorService")
public class SupervisorServiceImpl extends DataServiceImpl<Supervisor> implements SupervisorService {

    @Dao
    private SupervisorDao supervisorDao;
    
    /* (non-Javadoc)
     * @see com.ihg.hiex.admin.service.account.SupervisorService#loadByEmail(java.lang.String)
     */
    public Supervisor loadByEmail(String email) {
        return supervisorDao.loadByEmail(email);
    }
    
    /* (non-Javadoc)
     * @see com.ihg.hiex.admin.service.account.SupervisorService#edit(com.ihg.hiex.entity.user.Supervisor)
     */
    public void edit(Supervisor supervisor) {
        
        // 1. update account
        Account account = supervisor.getAccount();
        account.edit(supervisor.getTelephone());
        genericDaoSupport.update(account);

        // 2. update supervisor
        genericDaoSupport.update(supervisor.edit());
        
    }

}
